|
|
|
|
|
|
|
you tween, you must provide enough key frames to determine the route the program takes between them. |
|
|
|
|
|
|
|
|
When you use linear interpolation to compute tween values, values vary smoothly between key frames. When you reach a key frame, however, there is a sudden change in the direction the key values are moving. In the previous tweens, the key values have been moving toward this key frame's value. Now they start moving toward those of the next key frame. Figure 9.5 shows a graph of one of an animation's parameters. For instance, this might be the value of the X coordinate of one of a segment's endpoints during endpoint interpolation. Notice the sharp changes in direction at the key frames. |
|
|
|
|
|
|
|
|
Sudden changes in the movement of the parameters can make the animation appear jerky. The file Square3.twe describes four frames that animate a moving square. The square begins in the upper left of the screen, moves down to the lower left, across to the lower right, and then up to the upper right. The square makes large changes in direction when it reaches the key frames. If you load the file in program TweenEnd, create 10 tweens between the key frames, and run the animation, the motion changes abruptly when it reaches the key frames. |
|
|
|
|
|
|
|
|
One way to reduce the jerkiness is to create more key frames. By making the differences between the key frames smaller, you reduce the size of the jerks. Of course, this approach requires that you create and store more key frames. |
|
|
|
|
|
|
|
|
Another way to prevent this jerkiness is to smooth the values used by the tweens as shown in Figure 9.6. Instead of using linear interpolation, you can compute values using some sort of smoothing function. One such function is a Hermite curve. |
|
|
|
|
|
|
|
|
Suppose you want to create a smoothly varying set of values connecting the two endpoints (x1, y1) and (x2, y2). Suppose you also want the tangents at the two endpoints to |
|
|
|
|
|
|
|
|
Figure 9.5
Linear interpolation causes sudden changes in
a variable's direction of change at key frames. |
|
|
|
|
|